package com.zrrd.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author WanJl
 * @version 1.0
 * @title SpringMvcSupport
 * @description 设置静态资源访问过滤配置类
 * @create 2024/1/29 10:06
 */
//为了防止要单独加载springConfig核心配置类的，误加载当前配置，
// 那么将当前的配置类设定为核心配置类，而不是由springConfig引入
@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {
    //设置静态资源访问过滤，当前类需要设置为配置类，并被扫描加载
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/**")
                .addResourceLocations("/");
        //当访问/pages/????时候，从/pages目录下查找内容
        registry.addResourceHandler("/pages/**")
                .addResourceLocations("/pages/");
        registry.addResourceHandler("/js/**")
                .addResourceLocations("/js/");
        registry.addResourceHandler("/css/**")
                .addResourceLocations("/css/");
        registry.addResourceHandler("/plugins/**")
                .addResourceLocations("/plugins/");
    }
}